﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;

namespace ClassLibrary.DAO
{
    public class TblIntroducDAO
    {
        private DBService _db = null;
        public TblIntroducDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable InsUp_Intro(TblIntroduc intro, int mode)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblIntroduc_InsUp",
                    new string[] { "@ID", "@Introduction", "@Mode" }, new object[] { intro.IDIntroduc, intro.Introduction, mode }, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetIntro()
        {
            DataTable dt = null;
            dt = _db.ExeSP_DataTable("select * from TblIntroduc", false, CommandType.Text);
            return dt;
        }
        public DataTable GetIntroByID(int Id)
        {
            DataTable dt = null;
            dt = _db.ExeSP_DataTable("select * from TblIntroduc where IDIntroduc = @Id", new string[]{"@Id"}, new object[]{Id}, CommandType.Text);
            return dt;
        }
    }
}
